<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../../org/angular.min.js"></script>
    <script src="../../org/jquery.min.js"></script>
</head>

<body ng-app="app" ng-controller="ctrl">
    <span ng-bind="name"></span>
    <script>
        var m = angular.module('app', []);
        m.controller('ctrl', ['$scope', '$http', function($scope, $http) {
            //第一种方式
            // $http({
            //     url: './1.php',
            //     method: 'post',
            //     data: {
            //         id: 1,
            //         name: 'zyx'
            //     },
            //     headers: {
            //         'Content-Type': 'application/json'
            //     }
            // }).then(function(res) {
            //     console.log(res.data);
            // })
            //第二种方式
            $http({
                url: './1.php',
                method: 'post',
                //使用jquery的param方法序列化数据
                data: $.param({
                    id: 1,
                    name: 'zyx',
                    city: '哈尔滨'
                }),
                //指定头信息，告诉http协议，按php表单发送数据
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded'
                }
            }).then(function(res) {
                console.log(res.data);
            })
        }])
    </script>
</body>

</html>
